Open
Conversation
peterDijk
commented
Dec 6, 2024
| def count(self) -> int: | ||
| products = self.all() | ||
| return len(list(products)) | ||
| # pylint: disable=not-callable |
Owner
Author
There was a problem hiding this comment.
why needed here but not at func.sum() ??
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
adding pagination was done in minutes, arriving to tests in current state took some hours of trying and failing.
My issue was with seeding many items, and asserting the order of products.
before i was only testing the list endpoint with 2 manually seeded products.
I started with seeding 100 items, but the order of products (which is ordered by date_added desc) was all over the place.
I did realize quick the seeded products had a date_added that was all similar.
first learning: have Date column including milliseconds.
I still had products that were in added in the exact same millisecond. Tried. a lot of things with adding sleep in the seed method, awaiting the seed etc. Tests were taking a very long time now, did succeed, but not reliable, sometimes still similar date_added.
Stopped with not asserting the items order and just asserting the items returned.
Until driving the car suddenly I realized 'of course i just have to set the date_added myself in the seed, setting a second later for each product. --> quick google I found this in python is done with using
timedeltasecond learning: in testing, set as many values yourself when you assert the outcome based on those values